<template>
  <a-select
    v-bind="$attrs"
    value="上 传"
    :dropdownMatchSelectWidth="false"
    :disabled="disabled"
  >
    <a-select-option value="local">
      <file-conflict-presets-drawer />
    </a-select-option>
    <!-- <a-select-option value="db"><upload-db /></a-select-option>
    <a-select-option value="supercomputing">
      <upload-supercomputing />
    </a-select-option> -->
  </a-select>
</template>
<script setup>
import { ref, computed } from 'vue'
import FileConflictPresetsDrawer from './file-conflict-presets-upload-local-drawer.vue'
import UploadDb from './upload-db.vue'
import UploadSupercomputing from './upload-supercomputing.vue'
import {
  useDataSource,
  useTreeSelectedInfo,
  useLockForInUse,
} from './provide-context.js'
/**
 * 全局
 */
let dataSource = useDataSource()
let treeSelectedInfo = useTreeSelectedInfo()
let lockForInUse = useLockForInUse()
/**
 * 本地上传
 */
let animationRef = ref()
function onUploadLocalStart() {
  animationRef.value.play()
}

/**
 * 是否在创建中
 */
// let createing = computed(() =>
//   dataSource.value.some(({ editing }) => editing === true),
// )
let disabled = computed(() => {
  return (
    !treeSelectedInfo.value ||
    (treeSelectedInfo.value.children || []).length > 0 ||
    // dataSource.value.length === 0
    // createing.value ||
    !!lockForInUse.value
  )
})
</script>
